package com.edu.exam.entity.quality.monitoring;

import com.edu.exam.enums.quality.PatrolRecordStatus;
import com.edu.exam.enums.quality.PatrolReviewStatus;
import com.edu.exam.enums.quality.PatrolApprovalStatus;
import com.edu.exam.enums.quality.PatrolComplianceRating;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 巡考记录实体类
 *
 * 负责管理巡考过程中的记录信息
 * 根据E-05-巡考管理模块设计实现
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public class PatrolRecord {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Column(name = "task_id", nullable = false)
    private Long taskId;

    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Column(name = "user_name", nullable = false, length = 100)
    private String userName;

    @Column(name = "organization_status", nullable = false, columnDefinition = "TEXT")
    private String organizationStatus; // 考试组织情况

    @Column(name = "exam_room_environment", nullable = false, columnDefinition = "TEXT")
    private String examRoomEnvironment; // 考场环境状况

    @Column(name = "equipment_status", nullable = false, columnDefinition = "TEXT")
    private String equipmentStatus; // 设备设施状况

    @Column(name = "overall_assessment", columnDefinition = "TEXT")
    private String overallAssessment; // 总体评价

    @Column(name = "photo_urls", columnDefinition = "TEXT")
    private String photoUrls; // 照片URL列表（JSON格式）

    @Column(name = "record_time", nullable = false)
    private LocalDateTime recordTime;

    @Column(name = "submit_time")
    private LocalDateTime submitTime;

    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false, length = 20)
    private PatrolRecordStatus status = PatrolRecordStatus.DRAFT;

    @Column(name = "remarks", columnDefinition = "TEXT")
    private String remarks;

    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    @Column(name = "updated_time", nullable = false)
    private LocalDateTime updatedTime;

    @Column(name = "location_details", length = 500)
    private String locationDetails; // 具体位置详情

    @Column(name = "weather_during_patrol", length = 200)
    private String weatherDuringPatrol; // 巡考时天气情况

    @Column(name = "temperature")
    private Integer temperature; // 温度

    @Column(name = "humidity")
    private Integer humidity; // 湿度

    @Column(name = "noise_level", length = 100)
    private String noiseLevel; // 噪音水平

    @Column(name = "lighting_conditions", length = 200)
    private String lightingConditions; // 光照条件

    @Column(name = "ventilation_status", length = 200)
    private String ventilationStatus; // 通风状况

    @Column(name = "cleanliness_status", length = 200)
    private String cleanlinessStatus; // 清洁状况

    @Column(name = "security_status", length = 200)
    private String securityStatus; // 安全状况

    @Column(name = "emergency_exits", length = 200)
    private String emergencyExits; // 紧急出口状况

    @Column(name = "fire_safety", length = 200)
    private String fireSafety; // 消防安全

    @Column(name = "first_aid_kit", length = 200)
    private String firstAidKit; // 急救箱状况

    @Column(name = "student_attendance", columnDefinition = "TEXT")
    private String studentAttendance; // 学生出勤情况

    @Column(name = "invigilator_presence", length = 200)
    private String invigilatorPresence; // 监考员在场情况

    @Column(name = "exam_materials", columnDefinition = "TEXT")
    private String examMaterials; // 考试材料情况

    @Column(name = "seating_arrangement", columnDefinition = "TEXT")
    private String seatingArrangement; // 座位安排

    @Column(name = "time_management", length = 200)
    private String timeManagement; // 时间管理情况

    @Column(name = "discipline_status", columnDefinition = "TEXT")
    private String disciplineStatus; // 纪律状况

    @Column(name = "special_circumstances", columnDefinition = "TEXT")
    private String specialCircumstances; // 特殊情况

    @Column(name = "improvement_suggestions", columnDefinition = "TEXT")
    private String improvementSuggestions; // 改进建议

    @Column(name = "follow_up_actions", columnDefinition = "TEXT")
    private String followUpActions; // 后续行动

    @Column(name = "risk_assessment", columnDefinition = "TEXT")
    private String riskAssessment; // 风险评估

    @Column(name = "compliance_rating", length = 20)
    @Enumerated(EnumType.STRING)
    private PatrolComplianceRating complianceRating; // 合规评级

    @Column(name = "quality_score")
    private Double qualityScore; // 质量评分（0-100）

    @Column(name = "completion_score")
    private Double completionScore; // 完成度评分（0-100）

    @Column(name = "satisfaction_score")
    private Double satisfactionScore; // 满意度评分（0-100）

    @Column(name = "efficiency_score")
    private Double efficiencyScore; // 效率评分（0-100）

    @Column(name = "overall_score")
    private Double overallScore; // 总体评分（0-100）

    @Column(name = "checklist_items", columnDefinition = "TEXT")
    private String checklistItems; // 检查项目清单（JSON格式）

    @Column(name = "issue_summary", columnDefinition = "TEXT")
    private String issueSummary; // 问题摘要

    @Column(name = "positive_observations", columnDefinition = "TEXT")
    private String positiveObservations; // 积极观察

    @Column(name = "concerns_raised", columnDefinition = "TEXT")
    private String concernsRaised; // 关注问题

    @Column(name = "recommendations", columnDefinition = "TEXT")
    private String recommendations; // 建议

    @Column(name = "next_steps", columnDefinition = "TEXT")
    private String nextSteps; // 下一步行动

    @Column(name = "additional_notes", columnDefinition = "TEXT")
    private String additionalNotes; // 附加说明

    @Column(name = "supervisor_review", columnDefinition = "TEXT")
    private String supervisorReview; // 主管审查

    @Column(name = "reviewer_id")
    private Long reviewerId; // 审查人ID

    @Column(name = "reviewer_name", length = 100)
    private String reviewerName; // 审查人姓名

    @Column(name = "review_time")
    private LocalDateTime reviewTime; // 审查时间

    @Column(name = "review_status", length = 20)
    @Enumerated(EnumType.STRING)
    private PatrolReviewStatus reviewStatus = PatrolReviewStatus.PENDING;

    @Column(name = "review_comments", columnDefinition = "TEXT")
    private String reviewComments; // 审查意见

    @Column(name = "approval_status", length = 20)
    @Enumerated(EnumType.STRING)
    private PatrolApprovalStatus approvalStatus = PatrolApprovalStatus.PENDING;

    @Column(name = "approved_by", length = 100)
    private String approvedBy; // 审批人

    @Column(name = "approval_time")
    private LocalDateTime approvalTime; // 审批时间

    @Column(name = "approval_comments", columnDefinition = "TEXT")
    private String approvalComments; // 审批意见

    @Column(name = "version_number")
    private Integer versionNumber = 1; // 版本号

    @Column(name = "archived")
    private Boolean archived = false; // 是否归档

    @Column(name = "archive_time")
    private LocalDateTime archiveTime; // 归档时间

    @Column(name = "archive_reason", length = 500)
    private String archiveReason; // 归档原因

    @Column(name = "tags", length = 500)
    private String tags; // 标签（逗号分隔）

    @Column(name = "metadata", columnDefinition = "TEXT")
    private String metadata; // 元数据（JSON格式）



}